<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			function loadScript(url, func) {
				var head = document.head || document.getElementByTagName('head')[0];
				var script = document.createElement('script');
				script.src = url;

				script.onload = script.onreadystatechange = function() {
					if(!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') {
						func();
						script.onload = script.onreadystatechange = null;
					}
				};

				head.insertBefore(script, 0);
			}
			//因为服务端传回 的脚本 为 window.baidu.sug({q:"w",p:false,s:["我的前半生","微信网页版","微信公众平台官网","网易云音乐","微信公众平台","王者荣耀","微博","微信","我们的少年时代","网易邮箱"]});
			//所以 本地必须有  window.baidu对象且有.sug方法 才能解析这个脚本
			//想想 script src="../js/jquery-3.1.1.js" 时脚本是怎么载入的
			window.baidu = {
			  sug: function(data){
			    console.log(data.s);
			  }
			}
			function funload(){
				
				loadScript('http://suggestion.baidu.com/su?wd=w',
				function(){//这个函数是额外的没有多大用
					console.log('loaded')
					}
				);
			}
			
		</script>
	</head>
	<body>
		<button onclick="funload()">请求并获取返回结果 jquery</button><br>
	</body>
</html>
